﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using HigLabo.WindowsAzure.RestService.Extensions;

namespace HigLabo.WindowsAzure.RestService.ServiceManagement
{
    public class RollbackUpdateOrUpgrade
    {
        public enum RollbackUpdateOrUpgradeMode
	    {
            auto,
            manual
	    }

        public static readonly String ElementName = "RollbackUpdateOrUpgrade";

        public RollbackUpdateOrUpgrade.RollbackUpdateOrUpgradeMode Mode { get; private set; }
        public Boolean Force { get; private set; }

        public RollbackUpdateOrUpgrade
            (RollbackUpdateOrUpgrade.RollbackUpdateOrUpgradeMode mode, Boolean force)
        {
            this.Mode = mode;
            this.Force = force;
        }
        public String CreateText()
        {
            var ns = XNamespace.Get("http://schemas.microsoft.com/windowsazure");
            var doc = new XDocument();
            var root = new XElement(ns.GetName(ElementName));
            doc.Add(root);
            root.Add(new XElement(ns.GetName("Mode"), this.Mode.ToString()));
            root.Add(new XElement(ns.GetName("Force"), this.Force.ToString().ToLower()));
            return doc.ToString();
        }
    }
}
